Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP-7549: validator client #14158

Merged
merged 9 commits into from
Jul 11, 2024
Merged

EIP-7549: validator client #14158

merged 9 commits into from
Jul 11, 2024

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Jun 28, 2024

What type of PR is this?

Feature

What does this PR do? Why is it needed?

Implements the following changes for EIP-7549

  • validator client code
    • submitting Electra attestations
    • submitting Electra aggregates
  • server code
    • ProposeAttestationElectra

@rkapka rkapka changed the title Eip 7549 vc EIP-7549: validator client Jun 28, 2024
@rkapka rkapka added Ready For Review A pull request ready for code review API Api related tasks Validator Client Electra electra hardfork labels Jul 2, 2024
@rkapka rkapka marked this pull request as ready for review July 2, 2024 13:13
@rkapka rkapka requested a review from a team as a code owner July 2, 2024 13:13
Copy link
Member

@prestonvanloon prestonvanloon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions, overall looks good though

Comment on lines +47 to +60
versionAtts := make([]ethpb.Att, 0, len(atts))
if postElectra {
for _, a := range atts {
if a.Version() == version.Electra {
versionAtts = append(versionAtts, a)
}
}
} else {
for _, a := range atts {
if a.Version() == version.Phase0 {
versionAtts = append(versionAtts, a)
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests for this function logic? If it's too complicated, consider moving this filtering logic to its own method and testing that.

Comment on lines +192 to +203
if len(a) == 0 {
return a
}

var limit uint64
if a[0].Version() == version.Phase0 {
limit = params.BeaconConfig().MaxAttestations
} else {
limit = params.BeaconConfig().MaxAttestationsElectra
}
if uint64(len(a)) > limit {
return a[:limit]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be tested?

},
})
go func() {
ctx = trace.NewContext(context.Background(), trace.FromContext(ctx))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this line?

Suggested change
ctx = trace.NewContext(context.Background(), trace.FromContext(ctx))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, but it was there previously. I am a little scared to change this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's safe to delete it.

What this line of code does is "create a new context, which does not inherit any deadline from the parent, but includes all of the trace/span metadata from the parent context".

However, this isn't even used... so let's delete it

Data: data,
AggregationBits: aggregationBitfield,
Signature: sig,
// TODO: Extend to Electra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slasher logic which hasn't been updated to Electra yet. It is non-trivial and needs more discussion.

Comment on lines 196 to 208
if postElectra {
span.AddAttributes(
trace.Int64Attribute("slot", int64(slot)), // lint:ignore uintcast -- This conversion is OK for tracing.
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationDataRoot)),
trace.StringAttribute("committeeBitfield", fmt.Sprintf("%#x", committeeBits)),
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)),
trace.Int64Attribute("justifiedEpoch", int64(data.Source.Epoch)),
trace.Int64Attribute("targetEpoch", int64(data.Target.Epoch)),
trace.StringAttribute("aggregationBitfield", fmt.Sprintf("%#x", aggregationBitfield)),
)
} else {
span.AddAttributes(
trace.Int64Attribute("slot", int64(slot)), // lint:ignore uintcast -- This conversion is OK for tracing.
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationDataRoot)),
trace.Int64Attribute("committeeIndex", int64(data.CommitteeIndex)),
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)),
trace.Int64Attribute("justifiedEpoch", int64(data.Source.Epoch)),
trace.Int64Attribute("targetEpoch", int64(data.Target.Epoch)),
trace.StringAttribute("aggregationBitfield", fmt.Sprintf("%#x", aggregationBitfield)),
)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if postElectra {
span.AddAttributes(
trace.Int64Attribute("slot", int64(slot)), // lint:ignore uintcast -- This conversion is OK for tracing.
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationDataRoot)),
trace.StringAttribute("committeeBitfield", fmt.Sprintf("%#x", committeeBits)),
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)),
trace.Int64Attribute("justifiedEpoch", int64(data.Source.Epoch)),
trace.Int64Attribute("targetEpoch", int64(data.Target.Epoch)),
trace.StringAttribute("aggregationBitfield", fmt.Sprintf("%#x", aggregationBitfield)),
)
} else {
span.AddAttributes(
trace.Int64Attribute("slot", int64(slot)), // lint:ignore uintcast -- This conversion is OK for tracing.
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationDataRoot)),
trace.Int64Attribute("committeeIndex", int64(data.CommitteeIndex)),
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)),
trace.Int64Attribute("justifiedEpoch", int64(data.Source.Epoch)),
trace.Int64Attribute("targetEpoch", int64(data.Target.Epoch)),
trace.StringAttribute("aggregationBitfield", fmt.Sprintf("%#x", aggregationBitfield)),
)
}
span.AddAttributes(
trace.Int64Attribute("slot", int64(slot)), // lint:ignore uintcast -- This conversion is OK for tracing.
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationDataRoot)),
trace.StringAttribute("committeeBitfield", fmt.Sprintf("%#x", committeeBits)),
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)),
trace.Int64Attribute("justifiedEpoch", int64(data.Source.Epoch)),
trace.Int64Attribute("targetEpoch", int64(data.Target.Epoch)),
trace.StringAttribute("aggregationBitfield", fmt.Sprintf("%#x", aggregationBitfield)),
)
if postElectra {
span.AddAttributes(
trace.StringAttribute("committeeBitfield", fmt.Sprintf("%#x", committeeBits)),
)
} else {
span.AddAttributes(
trace.Int64Attribute("committeeIndex", int64(data.CommitteeIndex)),
)
}

prestonvanloon
prestonvanloon previously approved these changes Jul 8, 2024
@rkapka rkapka enabled auto-merge July 8, 2024 17:56

root, err := att.GetData().HashTreeRoot()
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not tree hash attestation: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, status.Errorf(codes.Internal, "Could not tree hash attestation: %v", err)
return nil, status.Errorf(codes.Internal, "Could not get attestation hash tree: %v", err)

if err != nil {
continue
return nil, errors.Wrap(err, "failed to create attestation ID")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping errors the same

Suggested change
return nil, errors.Wrap(err, "failed to create attestation ID")
return nil, errors.Wrap(err, "could not create attestation ID")

Copy link
Member

@prestonvanloon prestonvanloon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Please address @saolyn comments in a follow up PR

@rkapka rkapka added this pull request to the merge queue Jul 11, 2024
Merged via the queue into develop with commit 365c625 Jul 11, 2024
16 of 17 checks passed
@rkapka rkapka deleted the eip-7549-vc branch July 11, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks Electra electra hardfork Ready For Review A pull request ready for code review Validator Client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants